import { mock, Random } from "mockjs";
import type { MockMethod } from 'vite-plugin-mock'

/**
 * issues
 * - 使用Random.dataImage会报错
 * - 必须使用type导入MockMethod
 */

const { records } = mock({
  'records|10': [{
    c_id: '00',
    c_duty: '@cword(2, 5)',
    ts_ctime: '@datetime()',
    field1: '@cword(2, 5)',
    field2: '@cword(2, 5)'
  }]
});


const { records: table1 } = mock({
  'records|10': [{
    c_number: '001122',
    c_name: '@cname',
    id: '@id',
    'c_did|1': [0, 1],
    'c_dtid': [0, 1],
    c_tele: '0551-1234567',
    'i_sex|1': [0, 1],
    'c_education|1': [0, 1],
    c_id: '@id',
    c_address: '@county(true)',
    dt_join: '@datetime',
    dt_left: '@datetime',
    'i_type|1': [0, 1],
    'i_probation|1': [0, 1],
    dt_endpro: '@datetime',
    'i_status|1': [0, 1, 2],
    'i_manager|1': [0, 1],
    'i_attendance|1': [0, 1],
    c_headimg: Random.image('100x100', '#50B347', '#FFF', 'B'),
    c_mobile: '18823234545',
    c_wxid: 'wx_123',
    ts_ctime: '@datetime',
  }]
});


export default [
  {
    url: '/assist/table',
    method: 'post',
    response: {
      code: 200,
      data: {
        records: records,
        total: 15
      },
      msg: '通用表格数据'
    }
  }, {
    url: '/assist/table1',
    method: 'post',
    response: {
      code: 200,
      data: {
        records: table1,
        total: 15
      },
      msg: '员工信息'
    }
  }
] as MockMethod[]